home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / WINSYS.PAK / REGISTRY.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  38KB  |  1,479 lines

  1. //----------------------------------------------------------------------------
  2. // Borland WinSys Library
  3. // Copyright (c) 1994, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   5.25  $
  6. //
  7. // General Registry access & registration implementation
  8. //   TRegKey, TRegValue, TRegKeyIterator, TRegValueIterator
  9. //   TXRegistry
  10. //   TRegItem, TRegList, TRegLink - associative array of localizable string parameters
  11. //   OC registry functions
  12. //----------------------------------------------------------------------------
  13. #if !defined(WINSYS_REGISTRY_H)
  14. #define WINSYS_REGISTRY_H
  15.  
  16. #if !defined(WINSYS_EXBASE_H)
  17. # include <winsys/exbase.h>
  18. #endif
  19. #if !defined(WINSYS_WSYSINC_H)
  20. # include <winsys/wsysinc.h>
  21. #endif
  22. #if !defined(WINSYS_LCLSTRNG_H)
  23. # include <winsys/lclstrng.h>
  24. #endif
  25. #if !defined(SERVICES_MEMORY_H)
  26. # include <services/memory.h>
  27. #endif
  28. #if !defined(SERVICSE_CHECKS_H)
  29. # include <services/checks.h>
  30. #endif
  31. #if !defined(__TCHAR_H)
  32. # include <tchar.h>
  33. #endif
  34. #if defined(BI_PLAT_WIN16)
  35. # if !defined(_INC_SHELLAPI)
  36. #   include <shellapi.h>
  37. # endif
  38. # if !defined(_STORAGE_H_)
  39. #   include <storage.h>
  40. # endif
  41. #endif
  42.  
  43. #if defined(BI_PLAT_WIN16)
  44.   typedef uint32 REGSAM;
  45.   typedef uint32 SECURITY_INFORMATION;
  46.   typedef void*  PSECURITY_DESCRIPTOR;
  47. # define KEY_ALL_ACCESS 0    // Value doesn't matter since never seen
  48. #endif
  49.  
  50. class _EXPCLASS istream;
  51. class _EXPCLASS ostream;
  52.  
  53. #if defined(BI_NAMESPACE)
  54. namespace ClassLib {
  55. #endif
  56.  
  57. //----------------------------------------------------------------------------
  58. // Direct registry access classes. Can read & iterate as well as create and
  59. // write keys and value-data pairs
  60. //
  61.  
  62. //
  63. // class TRegKey
  64. // ~~~~~ ~~~~~~~
  65. // Encapsulation of a registration key
  66. //
  67. class TRegKeyIterator;
  68. class TRegKey {
  69.   public:
  70.     typedef HKEY THandle;
  71.  
  72.     // Enumeration used to specify whether a key should be created (or
  73.     // simply opened).
  74.     //
  75.     enum TCreateOK {
  76.       CreateOK,             // Create key if it does not exist
  77.       NoCreate              // Don't create, simply open
  78.     };
  79.  
  80.     // Create or open a key given a base key and a subkeyname. Security
  81.     // information is ignored in 16bit (and under Win95)
  82.     // Can also provide an ok-to-create or open-only indicator.
  83.     //
  84.     TRegKey(THandle baseKey,
  85.             const _TCHAR far* keyName,
  86.             REGSAM samDesired = KEY_ALL_ACCESS,
  87.             TCreateOK createOK = CreateOK);
  88.  
  89.     // Construct a key give the current position of a regkey iterator
  90.     //
  91.     TRegKey(const TRegKeyIterator& iter, REGSAM samDesired = KEY_ALL_ACCESS);
  92.  
  93.     // Contruct a key that is an alias to an existing HKEY
  94.     //
  95.     TRegKey(THandle aliasKey, bool shouldClose=false, const _TCHAR far* keyName = 0);
  96.    ~TRegKey();
  97.  
  98.     operator THandle() const;
  99.  
  100.     long DeleteKey(const _TCHAR far* subKeyName);
  101.     long NukeKey(const _TCHAR far* subKeyName);
  102.     long Flush() const;
  103.  
  104.     long GetSecurity(SECURITY_INFORMATION secInf, PSECURITY_DESCRIPTOR secDesc,
  105.                      uint32* secDescSize);
  106.     long SetSecurity(SECURITY_INFORMATION secInf, PSECURITY_DESCRIPTOR secDesc);
  107.  
  108.     // Saving & loading of this key & subKeys
  109.     //
  110.     long Save(const _TCHAR far* fileName);
  111.     long LoadKey(const _TCHAR far* subKeyName, const _TCHAR far* fileName);
  112.     long ReplaceKey(const _TCHAR far* subKeyName, const _TCHAR far* newFileName,
  113.                     const _TCHAR far* oldFileName);
  114.     long Restore(const _TCHAR far* fileName, uint32 options=0);
  115.     long UnLoadKey(const _TCHAR far* subKeyName);
  116.  
  117.     //long NotifyChangeKeyValue();
  118.  
  119.     // Some of these are initialized at ctor
  120.     //
  121.     long QueryInfo(_TCHAR far* class_, uint32* classSize, uint32* subkeyCount,
  122.                    uint32* maxSubkeySize, uint32* maxClassSize,
  123.                    uint32* valueCount, uint32* maxValueName,
  124.                    uint32* maxValueData, uint32* secDescSize,
  125.                    FILETIME far* lastWriteTime);
  126.  
  127.     const _TCHAR far* GetName() const;
  128.     uint32 GetSubkeyCount() const;
  129.     uint32 GetValueCount() const;
  130.  
  131.     // Special predefined root keys
  132.     //
  133.  
  134.   #if 0
  135.     //
  136.     // The following static objects cause a problem under system where
  137.     // the keys do no exist: instead of simply indicating a failure to
  138.     // open the key, the OS causes an access violation. The previous
  139.     // implementation did contain a __try/__except clause to handle these
  140.     // (see TRegKey's constructor in REGISTRY.CPP). Unfortunately, the
  141.     // exceptions are still caught by debuggers; furthermore, sometimes they
  142.     // render the system unstable ?!?!
  143.     //
  144.     // So, we'll replace the static objects with accessors - These keys
  145.     // should only be accessed on versions of the OS that supports them.
  146.     // You can make use of TSystem to determine the OS at runtime.
  147.     //
  148.     // NOTE: ClassesRoot and ClassesRootClsid are left as static objects
  149.     //       since they are commonly used keys which are supported by all
  150.     //       current versions of Windows. Changing these is likely to
  151.     //       break a fair amount of code. However, we recommend that all
  152.     //       new code use the accessors.
  153.     //
  154.     static TRegKey CurrentUser;
  155.     static TRegKey LocalMachine;
  156.     static TRegKey Users;
  157.     static TRegKey CurrentConfig;
  158.     static TRegKey DynData;
  159.     static TRegKey PerformanceData;
  160.  
  161.   #else
  162.  
  163.     static TRegKey ClassesRoot;
  164.     static TRegKey ClassesRootClsid;
  165.  
  166.     static TRegKey& CurrentUser()     { return GetCurrentUser();    }
  167.     static TRegKey& LocalMachine()    { return GetLocalMachine();   }
  168.     static TRegKey& Users()           { return GetUsers();          }
  169.     static TRegKey& CurrentConfig()   { return GetCurrentConfig();  }
  170.     static TRegKey& DynData()         { return GetDynData();        }
  171.     static TRegKey& PerformanceData() { return GetPerformanceData();}
  172.  
  173.   #endif
  174.  
  175.     // Accessors common/predefined registry keys
  176.     //
  177.     static TRegKey& GetClassesRoot();
  178.     static TRegKey& GetClassesRootClsid();
  179.     static TRegKey& GetCurrentUser();
  180.     static TRegKey& GetLocalMachine();
  181.     static TRegKey& GetUsers();
  182.     static TRegKey& GetCurrentConfig();
  183.     static TRegKey& GetDynData();
  184.     static TRegKey& GetPerformanceData();
  185.  
  186.     // Friend iterators only...?
  187.     //
  188.     long EnumKey(int index, _TCHAR far* subKeyName, int subKeyNameSize) const;
  189.  
  190.     // Older, nameless subkey+(Default) value access
  191.     //
  192.     long SetDefValue(const _TCHAR far* subkeyName, uint32 type,
  193.                      const _TCHAR far* data, uint32 dataSize);
  194.     long QueryDefValue(const _TCHAR far* subkeyName, _TCHAR far* data,
  195.                        uint32* dataSize) const;
  196.  
  197.     // Newer, named value set & get functions. Subkeys must be opened
  198.     //
  199.     long SetValue(const _TCHAR far* valName, uint32 type, const uint8* data,
  200.                   uint32 dataSize) const;
  201.     long SetValue(const _TCHAR far* valName, uint32 data) const;
  202.     long QueryValue(const _TCHAR far* valName, uint32* type, uint8* data,
  203.                     uint32* dataSize) const;
  204.     long DeleteValue(const _TCHAR far* valName) const;
  205.  
  206.     // Friend iterators only...?
  207.     //
  208.     long EnumValue(int index, _TCHAR far* valueName, uint32& valueNameSize,
  209.                    uint32* type = 0, uint8* data = 0, uint32* dataSize = 0) const;
  210.  
  211.   protected:
  212.     THandle   Key;          // This Key's Handle
  213.     _TCHAR far* Name;         // This Key's Name
  214.     uint32    SubkeyCount;  // Number of subkeys
  215.     uint32    ValueCount;   // Number of value entries
  216.     bool      ShouldClose;  // Should this key be closed on destruction
  217. };
  218.  
  219.  
  220. //
  221. // class TRegValue
  222. // ~~~~~ ~~~~~~~~~
  223. // Encapsulation of a value-data entry within one registration key.
  224. //
  225. class TRegValueIterator;
  226. class TRegValue {
  227.   public:
  228.     TRegValue(const TRegKey& key, const _TCHAR far* name);
  229.     TRegValue(const TRegValueIterator& iter);
  230.    ~TRegValue();
  231.  
  232.     const _TCHAR far* GetName() const;
  233.     const uint32 GetDataType() const;
  234.     const uint32 GetDataSize() const;
  235.     const uint8* GetData() const;
  236.     operator uint32() const;
  237.     operator const _TCHAR far*() const;
  238.  
  239.     // Set the data and possibly type of this value
  240.     //
  241.     long Set(uint32 type, uint8* data, uint32 dataSize);
  242.     long Set(uint32 data);
  243.     long Set(const _TCHAR far* data);
  244.     void operator =(uint32 v);
  245.     long Delete();
  246.     void operator =(const _TCHAR far* v);
  247.  
  248.     void RetrieveOnDemand() const;
  249.  
  250.   private:
  251.     const TRegKey&  Key;      // Key that this value lives in
  252.     const _TCHAR far* Name;     // Working name pointer
  253.     _TCHAR far*       AName;    // Allocated space for name if needed
  254.  
  255.     // Data information. 
  256.     uint32          DataType; // Type code for value data
  257.     mutable uint8*  Data;     // Value data itself, allocated
  258.     uint32          DataSize; // Size in bytes of Data
  259. };
  260.  
  261. //
  262. // class TRegKeyIterator
  263. // ~~~~~ ~~~~~~~~~~~~~~~
  264. // Iterator for walking thru the subkeys of a key
  265. //
  266. class TRegKeyIterator {
  267.   public:
  268.     TRegKeyIterator(const TRegKey& key);
  269.  
  270.     operator bool();
  271.  
  272.     uint32 operator ++();
  273.     uint32 operator ++(int);
  274.     uint32 operator --();
  275.     uint32 operator --(int);
  276.     uint32 operator [](int index);
  277.  
  278.     int             Current() const;
  279.     const TRegKey&  BaseKey() const;
  280.  
  281.     void Reset();
  282.  
  283.   private:
  284.     const TRegKey& Key;
  285.     int            Index;
  286. };
  287.  
  288. //
  289. // class TRegValueIterator
  290. // ~~~~~ ~~~~~~~~~~~~~~~~~
  291. // Iterator for walking thru the values of a key
  292. //
  293. class TRegValueIterator {
  294.   public:
  295.     TRegValueIterator(const TRegKey& regKey);
  296.  
  297.     operator bool();
  298.  
  299.     uint32 operator ++();
  300.     uint32 operator ++(int);
  301.     uint32 operator --();
  302.     uint32 operator --(int);
  303.     uint32 operator [](int index);
  304.  
  305.     int            Current() const;
  306.     const TRegKey& BaseKey() const;
  307.  
  308.     void Reset();
  309.  
  310.   private:
  311.     const TRegKey& Key;
  312.     int            Index;
  313. };
  314.  
  315. //----------------------------------------------------------------------------
  316.  
  317. //
  318. // class TXRegistry
  319. // ~~~~~ ~~~~~~~~~~
  320. // Registry related exception class
  321. //
  322. class TXRegistry : public TXBase {
  323.   public:
  324.     TXRegistry(const _TCHAR* msg, const _TCHAR* key);
  325.     TXRegistry(const TXRegistry& copy);
  326.  
  327.     static void Check(long stat, const _TCHAR* key);
  328.  
  329.     const _TCHAR* Key;
  330. };
  331.  
  332.  
  333. //----------------------------------------------------------------------------
  334. // Registration parameter structures and formatting functions
  335. //
  336.  
  337. //
  338. // class TRegFormatHeap
  339. // ~~~~~ ~~~~~~~~~~~~~~
  340. // Used internally to provide buffers for formating registration strings
  341. //
  342. class TRegFormatHeap {
  343.   public:
  344.     TRegFormatHeap();
  345.    ~TRegFormatHeap();
  346.     _TCHAR*  Alloc(int spaceNeeded);
  347.   private:
  348.     struct TBlock {
  349.       TBlock*  Next;     // Next heap in chain
  350.       _TCHAR     Data[1];  // Allocated memory starts here
  351.     };
  352.     TBlock* Head;
  353. };
  354.  
  355. //
  356. // struct TRegItem
  357. // ~~~~~~ ~~~~~~~~
  358. // A single registration list entry
  359. //
  360. struct TRegItem {
  361.   _TCHAR*         Key;           // Non-localized parameter or registry subkey
  362.   TLocaleString Value;         // Localizable value for parameter or subkey
  363.  
  364.   // Used privately by REGFORMAT, REGSTATUS macros
  365.   //
  366.   static _TCHAR* RegFormat(int f, int a, int t, int d, TRegFormatHeap& heap);
  367.   static _TCHAR* RegFormat(const _TCHAR* f, int a, int t, int d, TRegFormatHeap& heap);
  368.   static _TCHAR* RegFlags(long flags, TRegFormatHeap& heap);
  369.   static _TCHAR* RegVerbOpt(int mf, int sf, TRegFormatHeap& heap);
  370.   static void  OverflowCheck();
  371. };
  372.  
  373. //
  374. // class TRegList
  375. // ~~~~~ ~~~~~~~~
  376. // A registration parameter table, composed of a list of TRegItems
  377. //
  378. class TRegList {
  379.   public:
  380.     TRegList(TRegItem* list);
  381.     const _TCHAR* Lookup(const _TCHAR* key,
  382.                        TLangId lang = TLocaleString::UserDefaultLangId);
  383.     TLocaleString& LookupRef(const _TCHAR* key);
  384.     const _TCHAR* operator[](const _TCHAR* key);
  385.  
  386.     TRegItem* Items;
  387. };
  388.  
  389. //
  390. // class TRegLink
  391. // ~~~~~ ~~~~~~~~
  392. // Registration link node, holding a pointer to a TRegList. Can be one in a
  393. // linked list.
  394. //
  395. class _WSYSCLASS TRegLink {
  396.   public:
  397.     TRegLink(TRegList& regList, TRegLink*& head);
  398.    ~TRegLink();
  399.     TRegLink*   GetNext() const;
  400.     TRegList&   GetRegList() const;
  401.  
  402.     static void AddLink(TRegLink*& head, TRegLink& newLink);
  403.     static bool RemoveLink(TRegLink*& head, TRegLink& remLink);
  404.  
  405.   protected:
  406.     TRegLink();           // Derived class must fill in ptrs
  407.     TRegLink*  Next;      // Next RegLink
  408.     TRegList*  RegList;   // Pointer to registration parameter table
  409. };
  410.  
  411. //
  412. // Registration parameter table macro definitions
  413. //
  414. #define BEGIN_REGISTRATION(regname) extern TRegItem regname##_list[]; \
  415.                                     extern TRegFormatHeap __regHeap; \
  416.                                     TRegList regname(regname##_list); \
  417.                                     static TRegItem regname##_list[] = {
  418. #define END_REGISTRATION {0,{0}} };
  419.  
  420. #define REGDATA(var,val) {#var, {val}},
  421. #define REGXLAT(var,val) {#var, {AUTOLANG_XLAT val}},
  422. #define REGITEM(key,val) {" " key, {val}},
  423. #define REGFORMAT(i,f,a,t,d) {"format" #i,{TRegItem::RegFormat(f,a,t,d,__regHeap)}},
  424. #define REGSTATUS(a,f) {"aspect" #a, {TRegItem::RegFlags(f,__regHeap)}},
  425. #define REGVERBOPT(v,mf,sf) {#v "opt",{TRegItem::RegVerbOpt(mf,sf,__regHeap)}},
  426. #define REGICON(i) {"iconindex",{TRegItem::RegFlags(i,__regHeap)}},
  427. #define REGDOCFLAGS(i) {"docflags",{TRegItem::RegFlags(i,__regHeap)}},
  428.  
  429. //
  430. // Buffer size is no longer needed, use the macro below
  431. //
  432. #define REGISTRATION_FORMAT_BUFFER(n) \
  433.   TRegFormatHeap __regHeap;
  434.  
  435. #define REGISTRATION_FORMAT_HEAP \
  436.   TRegFormatHeap __regHeap;
  437.  
  438. //----------------------------------------------------------------------------
  439. // Clipboard and registry data transfer format definitions
  440. //
  441.  
  442. const int ocrVerbLimit   = 8;  // maximum number of verbs registered per class
  443. const int ocrFormatLimit = 8;  // maximum number of data formats per class
  444.  
  445. //
  446. // Format: standard clipboard numeric format, or name of custom format
  447. //
  448. enum ocrClipFormat {
  449.   ocrText           =  1,  // CF_TEXT
  450.   ocrBitmap         =  2,  // CF_BITMAP
  451.   ocrMetafilePict   =  3,  // CF_METAFILEPICT
  452.   ocrSylk           =  4,  // CF_SYLK
  453.   ocrDif            =  5,  // CF_DIF
  454.   ocrTiff           =  6,  // CF_TIFF
  455.   ocrOemText        =  7,  // CF_OEMTEXT
  456.   ocrDib            =  8,  // CF_DIB
  457.   ocrPalette        =  9,  // CF_PALETTE
  458.   ocrPenData        = 10,  // CF_PENDATA
  459.   ocrRiff           = 11,  // CF_RIFF
  460.   ocrWave           = 12,  // CF_WAVE
  461.   ocrUnicodeText    = 13,  // CF_UNICODETEXT  Win32 only
  462.   ocrEnhMetafile    = 14,  // CF_ENHMETAFILE  Win32 only
  463. };
  464. #define ocrRichText          "Rich Text Format"
  465. #define ocrEmbedSource       "Embed Source"
  466. #define ocrEmbeddedObject    "Embedded Object"
  467. #define ocrLinkSource        "Link Source"
  468. #define ocrObjectDescriptor  "Object Descriptor"
  469. #define ocrLinkSrcDescriptor "Link Source Descriptor"
  470.  
  471. //
  472. // Aspect: view types supported by transfer
  473. //
  474. enum ocrAspect {
  475.   ocrContent   = 1,  // DVASPECT_CONTENT    normal display representation
  476.   ocrThumbnail = 2,  // DVASPECT_THUMBNAIL  picture appropriate for browser
  477.   ocrIcon      = 4,  // DVASPECT_ICON       iconized representation of object
  478.   ocrDocPrint  = 8,  // DVASPECT_DOCPRINT   print preview representation
  479. };
  480.  
  481. //
  482. // Medium: means of data transfer
  483. //
  484. enum ocrMedium {
  485.   ocrNull       = 0,
  486.   ocrHGlobal    = 1,  // TYMED_HGLOBAL  global memory handle
  487.   ocrFile       = 2,  // TYMED_FILE     data as contents of file
  488.   ocrIStream    = 4,  // TYMED_ISTREAM  instance of an IStream object
  489.   ocrIStorage   = 8,  // TYMED_ISTORAGE streams within an instance of IStorage
  490.   ocrGDI        = 16, // TYMED_GDI      GDI object in global handle
  491.   ocrMfPict     = 32, // TYMED_MFPICT   CF_METAFILEPICT containing global handle
  492.   ocrStaticMed  = 1024 // OLE 2 static object
  493. };
  494.  
  495. //
  496. // Direction: transfer directions supported
  497. //
  498. enum ocrDirection {
  499.   ocrGet    = 1,
  500.   ocrSet    = 2,
  501.   ocrGetSet = 3,
  502. };
  503.  
  504. //----------------------------------------------------------------------------
  505. // Miscellaneous registry definitions
  506. //
  507.  
  508. //
  509. // IOleObject miscellaneous status flags, defined for each or all aspects
  510. //
  511. enum ocrObjectStatus {
  512.   ocrRecomposeOnResize           = 1,   // request redraw on container resize
  513.   ocrOnlyIconic                  = 2,   // only useful context view is Icon
  514.   ocrInsertNotReplace            = 4,   // should not replace current select.
  515.   ocrStatic                      = 8,   // object is an OLE static object
  516.   ocrCantLinkInside              = 16,  // should not be the link source
  517.   ocrCanLinkByOle1               = 32,  // only used in OBJECTDESCRIPTOR
  518.   ocrIsLinkObject                = 64,  // set by OLE2 link for OLE1 compat.
  519.   ocrInsideOut                   = 128, // can be activated concurrently
  520.   ocrActivateWhenVisible         = 256, // hint to cntnr when ocrInsideOut set
  521.   ocrRenderingIsDeviceIndependent= 512, // no decisions made based on target
  522.   ocrNoSpecialRendering          = 512, // older enum for previous entry
  523. };
  524.  
  525. //
  526. // IOleObject verb menu flags
  527. //
  528. enum ocrVerbMenuFlags {
  529.   ocrGrayed      = 1,   // MF_GRAYED
  530.   ocrDisabled    = 2,   // MF_DISABLED
  531.   ocrChecked     = 8,   // MF_CHECKED
  532.   ocrMenuBarBreak= 32,  // MF_MENUBARBREAK
  533.   ocrMenuBreak   = 64,  // MF_MENUBAR
  534. };
  535.  
  536. //
  537. // IOleObject verb attribute flags
  538. //
  539. enum ocrVerbAttributes {
  540.   ocrNeverDirties      = 1,   // verb can never cause object to become dirty
  541.   ocrOnContainerMenu   = 2,   // only useful context view is Icon
  542. };
  543.  
  544. //
  545. // Entries for <usage> registration parameter, class factory registration mode
  546. //
  547. #define ocrSingleUse     "1"  // single client per instance
  548. #define ocrMultipleUse   "2"  // multiple clients per instance
  549. #define ocrMultipleLocal "3"  // multiple clients, separate inproc server
  550.  
  551. //----------------------------------------------------------------------------
  552. // High-level table based registration support
  553. //
  554.  
  555. //
  556. // class TRegTemplateList
  557. // ~~~~~ ~~~~~~~~~~~~~~~~
  558. // List of parameterized template strings that represent the actual entries to
  559. // be registered. List is indexed from 1 for used with param-list template
  560. // activation strings. See TRegParamList below.
  561. //
  562. class TRegTemplateList {
  563.   public:
  564.     TRegTemplateList(TRegKey& basekey, const _TCHAR* list[]);
  565.    ~TRegTemplateList();
  566.  
  567.     int      GetCount() const;
  568.     TRegKey& GetBaseKey();
  569.  
  570.     const _TCHAR* operator [](int i);
  571.  
  572.     // Enable/Disable and activate templates
  573.     //
  574.     void  DisableAll();
  575.     void  EnableAll();
  576.     void  Enable(int i);
  577.     void  Enable(const _TCHAR* set);
  578.  
  579.     void  Activate(int i);
  580.     void  Activate(const _TCHAR* set);
  581.  
  582.     bool  IsActive(int i) const;
  583.  
  584.   private:
  585.     TRegKey&     BaseKey;       // Registry key that these templates are based
  586.     const _TCHAR** List;          // List of templates
  587.     int          Count;         // # of templates in list
  588.     _TCHAR*        EnabledFlags;  // Which templates are currently enabled/active
  589. };
  590.  
  591. //
  592. // class TRegParamList
  593. // ~~~~~ ~~~~~~~~~~~~~
  594. // A list of param entries for use as an intermediate between a TRegList and
  595. // the actual template list used to generate the registration. Provides default
  596. // values in 'Default', and tags required templates using octal char entries in
  597. // 'TemplatesNeeded'
  598. //
  599. class TRegParamList {
  600.   public:
  601.     struct TEntry {
  602.       _TCHAR*  Param;    // Substituted parameter name
  603.       _TCHAR*  Default;  // Default value, 0 if no default & param is required
  604.       _TCHAR*  TemplatesNeeded; // Octal string list of template indices to activate
  605.     };
  606.  
  607.     TRegParamList(TEntry* list);
  608.    ~TRegParamList();
  609.  
  610.     int Find(const _TCHAR* param);   // Associative lookup of value by param
  611.     int GetCount() const;
  612.  
  613.     TEntry& operator [](int i);
  614.  
  615.     const _TCHAR*& Value(int i);
  616.     void   ResetDefaultValues();
  617.  
  618.   private:
  619.     TEntry*        List;
  620.     int            Count;
  621.     const _TCHAR**   Values;
  622. };
  623.  
  624. //
  625. // class TRegSymbolTable
  626. // ~~~~~ ~~~~~~~~~~~~~~~
  627. // High level symbol-based registry entry manipulation
  628. //
  629. class TRegSymbolTable {
  630.   public:
  631.     TRegSymbolTable(TRegKey& basekey, const _TCHAR* tplList[], TRegParamList::TEntry* paramList);
  632.  
  633.     void Init(_TCHAR* filter);
  634.     void UpdateParams(TLangId lang, TRegItem* item);
  635.     void StreamOut(TRegItem* item, ostream& out);
  636. //    void StreamIn(TRegItem* item, istream& in);
  637.  
  638.     TRegTemplateList Templates;
  639.     TRegParamList    Params;
  640.     int              UserKeyCount;
  641. };
  642.  
  643. //
  644. // class TRegistry
  645. // ~~~~~ ~~~~~~~~~
  646. // High level stream & list access to registry
  647. //
  648. class TRegistry {
  649.   public:
  650.     static int  Validate(TRegKey& baseKey, istream& in);  // Returns number of mismatched entries
  651.     static void Update(TRegKey& baseKey, istream& in);   // Writes lines to registry
  652. #pragma pack(push,4)
  653.     struct TUnregParams {
  654.       _TCHAR     Prepend;  // Optional char to prepend to key before removing
  655.       _TCHAR*    Name;     // Name of param
  656.       TRegKey* BaseKey;  // Key that that the param is based upon
  657.     };
  658. #pragma pack(pop)
  659.     static int  Unregister(TRegList& regInfo, TUnregParams* params, TRegItem* overrides = 0);
  660. };
  661.  
  662. #if defined(BI_NAMESPACE)
  663. }     // namespace ClassLib
  664. #endif
  665.  
  666. //----------------------------------------------------------------------------
  667. // TRegKey inlines
  668. //
  669.  
  670. //
  671. // Return the HANDLE identifying this registry key.
  672. //
  673. inline
  674. TRegKey::operator TRegKey::THandle() const
  675. {
  676.   return Key;
  677. }
  678.  
  679. //
  680. // Enumerate the subkeys of this registry key
  681. //
  682. inline long
  683. TRegKey::EnumKey(int index, _TCHAR far* subKeyName, int subKeyNameSize) const
  684. {
  685.   return ::RegEnumKey(Key, index, subKeyName, subKeyNameSize);
  686.   //::RegEnumKeyEx(); ??
  687. }
  688.  
  689. //
  690. // Delete the specified subkey of this registry key
  691. //
  692. inline long
  693. TRegKey::DeleteKey(const _TCHAR far* subKeyName)
  694. {
  695.   return ::RegDeleteKey(Key, subKeyName);
  696. }
  697.  
  698. //
  699. // Write the attribute of this key in the registry
  700. // Note: 32 bit only
  701. //
  702. inline long
  703. TRegKey::Flush() const
  704. {
  705. #if defined(BI_PLAT_WIN16)
  706.   return 0;
  707. #else
  708.   return ::RegFlushKey(Key);
  709. #endif
  710. }
  711.  
  712. //
  713. // Retrieve a copy of the security descriptor protecting this registry key.
  714. // Note: 32 bit only
  715. //
  716. inline long
  717. TRegKey::GetSecurity(SECURITY_INFORMATION secInf, PSECURITY_DESCRIPTOR secDesc,
  718.                      uint32* secDescSize)
  719. {
  720. #if defined(BI_PLAT_WIN16)
  721.   return 0;
  722. #else
  723.   return ::RegGetKeySecurity(Key, secInf, secDesc, secDescSize);
  724. #endif
  725. }
  726.  
  727. //
  728. // Set the security descriptor of this key
  729. // Note: 32 bit only
  730. //
  731. inline long
  732. TRegKey::SetSecurity(SECURITY_INFORMATION secInf, PSECURITY_DESCRIPTOR secDesc)
  733. {
  734. #if defined(BI_PLAT_WIN16)
  735.   return 0;
  736. #else
  737.   return ::RegSetKeySecurity(Key, secInf, secDesc);
  738. #endif
  739. }
  740.  
  741. //
  742. // Save this key and all of its subkeys and values to the specified file.
  743. // Note: 32 bit only
  744. //
  745. inline long
  746. TRegKey::Save(const _TCHAR far* fileName)
  747. {
  748. #if defined(BI_PLAT_WIN16)
  749.   return 0;
  750. #else
  751.   return ::RegSaveKey(Key, fileName, 0/*Security*/);
  752. #endif
  753. }
  754.  
  755. //
  756. // Create a subkey under HKEY_USER or HKEY_LOCAL_MACHINE and stores
  757. // registration information from a specified file into that subkey. This
  758. // registration information is in the form of a hive. A hive is a discrete
  759. // body of keys, subkeys, and values that is rooted at the top of the
  760. // registry hierarchy. A hive is backed by a single file and .LOG file.
  761. // Note: 32 bit only
  762. //
  763. inline long
  764. TRegKey::LoadKey(const _TCHAR far* subKeyName, const _TCHAR far* fileName)
  765. {
  766. #if defined(BI_PLAT_WIN16)
  767.   return 0;
  768. #else
  769.   return ::RegLoadKey(Key, subKeyName, fileName);
  770. #endif
  771. }
  772.  
  773. //
  774. // Replace the file backing this key and all its subkeys with another file,
  775. // so that when the system is next started, the key and subkeys will have
  776. // the values stored in the new file.
  777. // Note: 32 bit only
  778. //
  779. inline long
  780. TRegKey::ReplaceKey(const _TCHAR far* subKeyName, const _TCHAR far* newFileName,
  781.                     const _TCHAR far* oldFileName)
  782. {
  783. #if defined(BI_PLAT_WIN16)
  784.   return 0;
  785. #else
  786.   return ::RegReplaceKey(Key, subKeyName, newFileName, oldFileName);
  787. #endif
  788. }
  789.  
  790. //
  791. // Read the registry information in a specified file and copies it over this
  792. // key. This registry information may be in the form of a key and multiple
  793. // levels of subkeys.
  794. // Note: 32 bit only
  795. //
  796. inline long
  797. TRegKey::Restore(const _TCHAR far* fileName, uint32 options)
  798. {
  799. #if defined(BI_PLAT_WIN16)
  800.   return 0;
  801. #else
  802.   return ::RegRestoreKey(Key, fileName, options);
  803. #endif
  804. }
  805.  
  806. //
  807. // Unload this key and its subkeys from the registry.
  808. //
  809. // Note: 32 bit only
  810. inline long
  811. TRegKey::UnLoadKey(const _TCHAR far* subKeyName)
  812. {
  813. #if defined(BI_PLAT_WIN16)
  814.   return 0;
  815. #else
  816.   return ::RegUnLoadKey(Key, subKeyName);
  817. #endif
  818. }
  819.  
  820. //inline long TRegKey::NotifyChangeKeyValue() {}
  821.  
  822. //
  823. // Return the number of subkeys attached to this key
  824. //
  825. inline uint32
  826. TRegKey::GetSubkeyCount() const
  827. {
  828.   return SubkeyCount;
  829. }
  830.  
  831. //
  832. // Return the number of values attached to this key
  833. //
  834. inline uint32
  835. TRegKey::GetValueCount() const
  836. {
  837.   return ValueCount;
  838. }
  839.  
  840. //
  841. // Return a string identifying this key
  842. //
  843. inline const _TCHAR far*
  844. TRegKey::GetName() const
  845. {
  846.   return Name;
  847. }
  848.  
  849. //
  850. // Associate a value with this key
  851. //
  852. inline long
  853. TRegKey::SetValue(const _TCHAR far* valName, uint32 type, const uint8* data,
  854.                   uint32 dataSize) const
  855. {
  856. #if defined(BI_PLAT_WIN16)
  857.   return ::RegSetValue(Key, 0, type, (LPCSTR)data, dataSize);
  858. #else
  859.   return ::RegSetValueEx(Key, valName, 0, type, data, dataSize);
  860. #endif
  861. }
  862.  
  863. //
  864. // Associate a 4-byte value with this key
  865. // Note: 32 bit only
  866. //
  867. inline long
  868. TRegKey::SetValue(const _TCHAR far* valName, uint32 data) const
  869. {
  870. #if defined(BI_PLAT_WIN16)
  871.   return 0;  
  872. #else
  873.   return SetValue(valName, REG_DWORD, (uint8*)&data, sizeof data);
  874. #endif
  875. }
  876.  
  877. //
  878. // Retrieve the value associated with the unnamed value for this key
  879. //
  880. inline long
  881. TRegKey::QueryValue(const _TCHAR far* valName, uint32* type, uint8* data,
  882.                     uint32* dataSize) const
  883. {
  884. #if defined(BI_PLAT_WIN16)
  885.   return ::RegQueryValue(Key, 0, (LPSTR)data, (long*)dataSize);
  886. #else
  887.   return ::RegQueryValueEx(Key, valName, 0, type, data, dataSize);
  888. #endif
  889. }
  890.  
  891. //
  892. // Remove a named value from this registry key
  893. // Note: 32 bit only
  894. //
  895. inline long
  896. TRegKey::DeleteValue(const _TCHAR far* valName) const
  897. {
  898. #if defined(BI_PLAT_WIN16)
  899.   return 0;
  900. #else
  901.   return ::RegDeleteValue(Key, valName);
  902. #endif
  903. }
  904.  
  905. //
  906. // Set the default [unnamed] value associated with this key
  907. //
  908. inline long
  909. TRegKey::SetDefValue(const _TCHAR far* subkeyName, uint32 type,
  910.                      const _TCHAR far* data, uint32 dataSize)
  911. {
  912.   return ::RegSetValue(Key, subkeyName, type, data, dataSize);
  913. }
  914.  
  915. //
  916. // Retrieve the default [unnamed] value associated with this key
  917. //
  918. inline long
  919. TRegKey::QueryDefValue(const _TCHAR far* subkeyName, _TCHAR far* data,
  920.                        uint32* dataSize) const
  921. {
  922.   return ::RegQueryValue(Key, subkeyName, data, (long*)dataSize);
  923. }
  924.  
  925. //
  926. // Enumerate the values associated with this key.  Copy the value name and
  927. // data block associated with the passed index.
  928. // Note: 32 bit only
  929. //
  930. inline long
  931. TRegKey::EnumValue(int index, _TCHAR far* valueName, uint32& valueNameSize,
  932.                    uint32* type, uint8* data, uint32* dataSize) const
  933. {
  934. #if defined(BI_PLAT_WIN16)
  935.   if (valueName)
  936.     *valueName = 0;
  937.   return 0;
  938. #else
  939.   return ::RegEnumValue(Key, index, valueName, &valueNameSize, 0, type, data, dataSize);
  940. #endif
  941. }
  942.  
  943. //----------------------------------------------------------------------------
  944. // TRegValue inlines
  945. //
  946.  
  947. //
  948. // Return a string identifying this value
  949. //
  950. inline const _TCHAR far*
  951. TRegValue::GetName() const
  952. {
  953.   return Name;
  954. }
  955.  
  956. //
  957. // Return the type code for the data associated with this value
  958. //
  959. inline const uint32
  960. TRegValue::GetDataType() const
  961. {
  962.   return DataType;
  963. }
  964.  
  965. //
  966. // Return the size in bytes of the data associated with this value
  967. //
  968. inline const uint32
  969. TRegValue::GetDataSize() const
  970. {
  971.   return DataSize;
  972. }
  973.  
  974. //
  975. // Return the data associated with this value.
  976. //
  977. inline const uint8*
  978. TRegValue::GetData() const {
  979.   RetrieveOnDemand();
  980.   return Data;
  981. }
  982.  
  983. //
  984. // Return the data associated with this value as a 32bit unsigned integer
  985. //
  986. inline TRegValue::operator uint32() const
  987. {
  988.   return *(uint32*)GetData();           // Assumes dataType==REG_DWORD
  989. }
  990.  
  991. //
  992. // Return the data associated with this value as a const char*
  993. //
  994. inline TRegValue::operator const _TCHAR far*() const
  995. {
  996.   return (const _TCHAR far*)GetData();  // Assumes DataType==REG_SZ or sim.
  997. }
  998.  
  999. //
  1000. // Set the data associated with this value
  1001. // Note: 32 bit only
  1002. //
  1003. inline long
  1004. TRegValue::Set(uint32 data)
  1005. {
  1006. #if defined(BI_PLAT_WIN16)
  1007.   return 0; 
  1008. #else
  1009.   return Set(REG_DWORD, (uint8*)&data, sizeof data);
  1010. #endif
  1011. }
  1012.  
  1013. //
  1014. // Set the data associated with this value
  1015. //
  1016. inline long
  1017. TRegValue::Set(const _TCHAR far* data)
  1018. {
  1019. //  TString strData(data);
  1020. //  wchar_t* ustrData = strData;  
  1021.   return Set(REG_SZ, (uint8*)data, _tcslen(data));
  1022. }
  1023.  
  1024. //
  1025. // Remove this value from its associated key.
  1026. // Note: the state of this value object becomes undefined.
  1027. //
  1028. inline long
  1029. TRegValue::Delete()
  1030. {
  1031.   return Key.DeleteValue(Name);
  1032. }
  1033.  
  1034. //
  1035. // Set the data for this value to v
  1036. //
  1037. inline void
  1038. TRegValue::operator =(uint32 v)
  1039. {
  1040.   Set(DataType, (uint8*)&v, DataSize);
  1041. }
  1042.  
  1043. //
  1044. // Set the data for this value to v
  1045. //
  1046. inline void
  1047. TRegValue::operator =(const _TCHAR far* v)
  1048. {
  1049.   Set(DataType, (uint8*)v, _tcslen(v) + 1);
  1050. }
  1051.  
  1052. //----------------------------------------------------------------------------
  1053. // TRegKeyIterator inlines
  1054. //
  1055.  
  1056. //
  1057. // Create a subkey iterator for a registration key
  1058. //
  1059. inline
  1060. TRegKeyIterator::TRegKeyIterator(const TRegKey& key)
  1061. :
  1062.   Key(key),
  1063.   Index(0)
  1064. {
  1065. }
  1066.  
  1067. //
  1068. // Test the validity of this iterator.  True if the iterator's
  1069. // index is greater than or equal to 0 and less than the number
  1070. // of subkeys.
  1071. //
  1072. inline
  1073. TRegKeyIterator::operator bool()
  1074. {
  1075.   return Index >= 0 && Index < int(Key.GetSubkeyCount());
  1076. }
  1077.  
  1078. //
  1079. // Preincrement to the next subkey
  1080. //
  1081. inline uint32
  1082. TRegKeyIterator::operator ++()
  1083. {
  1084.   return ++Index;
  1085. }
  1086.  
  1087. //
  1088. // Postincrement to the next subkey
  1089. //
  1090. inline uint32
  1091. TRegKeyIterator::operator ++(int)
  1092. {
  1093.   return Index++;
  1094. }
  1095.  
  1096. //
  1097. // Predecrement to the previous subkey
  1098. //
  1099. inline uint32
  1100. TRegKeyIterator::operator --()
  1101. {
  1102.   return --Index;
  1103. }
  1104.  
  1105. //
  1106. // Postdecrement to the previous subkey
  1107. //
  1108. inline uint32
  1109. TRegKeyIterator::operator --(int)
  1110. {
  1111.   return Index--;
  1112. }
  1113.  
  1114. //
  1115. // Set the index of the iterator to the passed value.  Return the new index.
  1116. //
  1117. inline uint32
  1118. TRegKeyIterator::operator [](int index)
  1119. {
  1120.   PRECONDITION((index >= 0) && (index < int(Key.GetSubkeyCount())));
  1121.   return Index = index;
  1122. }
  1123.  
  1124. //
  1125. // Return the index to the current subkey
  1126. //
  1127. inline int
  1128. TRegKeyIterator::Current() const
  1129. {
  1130.   return Index;
  1131. }
  1132.  
  1133. //
  1134. // Return the registration key this iterator is bound to
  1135. //
  1136. inline const TRegKey&
  1137. TRegKeyIterator::BaseKey() const
  1138. {
  1139.   return Key;
  1140. }
  1141.  
  1142. //
  1143. // Reset the subkey index to zero
  1144. //
  1145. inline void
  1146. TRegKeyIterator::Reset()
  1147. {
  1148.   Index = 0;
  1149. }
  1150.  
  1151. //----------------------------------------------------------------------------
  1152. // TRegValueIterator inlines
  1153. //
  1154.  
  1155. //
  1156. // Create a value iterator for a registration key
  1157. //
  1158. inline
  1159. TRegValueIterator::TRegValueIterator(const TRegKey& regKey)
  1160. :
  1161.   Key(regKey),
  1162.   Index(0)
  1163. {
  1164. }
  1165.  
  1166. //
  1167. // Test the validity of this iterator.  True if the iterator's
  1168. // index is greater than or equal to 0 and less than the number
  1169. // of values.
  1170. //
  1171. inline
  1172. TRegValueIterator::operator bool()
  1173. {
  1174.   return Index >= 0 && Index < int(Key.GetValueCount());
  1175. }
  1176.  
  1177. //
  1178. // Preincrement to the next value
  1179. //
  1180. inline uint32
  1181. TRegValueIterator::operator ++()
  1182. {
  1183.   return ++Index;
  1184. }
  1185.  
  1186. //
  1187. // Postincrement to the next value
  1188. //
  1189. inline uint32
  1190. TRegValueIterator::operator ++(int)
  1191. {
  1192.   return Index++;
  1193. }
  1194.  
  1195. //
  1196. // Predecrement to the previous value
  1197. //
  1198. inline uint32
  1199. TRegValueIterator::operator --()
  1200. {
  1201.   return --Index;
  1202. }
  1203.  
  1204. //
  1205. // Postdecrement to the previous value
  1206. //
  1207. inline uint32
  1208. TRegValueIterator::operator --(int)
  1209. {
  1210.   return Index--;
  1211. }
  1212.  
  1213. //
  1214. // Set the index of the iterator to the passed value.  Return the new index.
  1215. //
  1216. inline uint32
  1217. TRegValueIterator::operator [](int index)
  1218. {
  1219.   PRECONDITION((index >= 0) && (index < int(Key.GetValueCount())));
  1220.   return Index = index;
  1221. }
  1222.  
  1223. //
  1224. // Return the index to the current value
  1225. //
  1226. inline int
  1227. TRegValueIterator::Current() const
  1228. {
  1229.   return Index;
  1230. }
  1231.  
  1232. //
  1233. // Return the registration key this iterator is bound to
  1234. //
  1235. inline const TRegKey&
  1236. TRegValueIterator::BaseKey() const
  1237. {
  1238.   return Key;
  1239. }
  1240.  
  1241. //
  1242. // Reset the value index to zero
  1243. //
  1244. inline void
  1245. TRegValueIterator::Reset()
  1246. {
  1247.   Index = 0;
  1248. }
  1249.  
  1250.  
  1251. //----------------------------------------------------------------------------
  1252. // TXRegistry inlines
  1253. //
  1254.  
  1255. //
  1256. // Creates a registry exception object.  msg points to an error message and
  1257. // key points to the name of the registry key that ObjectComponents was
  1258. // processing when the exception occurred.
  1259. //
  1260. inline
  1261. TXRegistry::TXRegistry(const _TCHAR* msg, const _TCHAR* key)
  1262. :
  1263.   TXBase(msg),
  1264.   Key(key)
  1265. {
  1266. }
  1267.  
  1268. //
  1269. // The copy constructor constructs a new registry exception object by copying
  1270. // the one passed as copy.
  1271. //
  1272. inline
  1273. TXRegistry::TXRegistry(const TXRegistry& src)
  1274. :
  1275.   TXBase(src),
  1276.   Key(src.Key)
  1277. {
  1278. }
  1279.  
  1280.  
  1281. //----------------------------------------------------------------------------
  1282. // TRegList inlines
  1283. //
  1284.  
  1285. //
  1286. // Create a registration parameter table, composed of a list of TRegItems
  1287. //
  1288. inline
  1289. TRegList::TRegList(TRegItem* list)
  1290. :
  1291.   Items(list)
  1292. {
  1293.   PRECONDITION(list);
  1294. }
  1295.  
  1296. //
  1297. // Return the value of the passed key as a const char*
  1298. //
  1299. inline const _TCHAR*
  1300. TRegList::operator[](const _TCHAR* key)
  1301. {
  1302.   PRECONDITION(key);
  1303.   return Lookup(key);
  1304. }
  1305.  
  1306.  
  1307. //----------------------------------------------------------------------------
  1308. // TRegLink inlines
  1309. //
  1310.  
  1311. //
  1312. // Registration link node destructor
  1313. //
  1314. inline
  1315. TRegLink::~TRegLink()
  1316. {
  1317. }
  1318.  
  1319. //
  1320. // Return a pointer to the next link
  1321. //
  1322. inline TRegLink*
  1323. TRegLink::GetNext() const
  1324. {
  1325.   return Next;
  1326. }
  1327.  
  1328. //
  1329. // Return a pointer to registration parameter table (reglist)
  1330. //
  1331. inline TRegList&
  1332. TRegLink::GetRegList() const
  1333. {
  1334.   return *RegList;
  1335. }
  1336.  
  1337. //
  1338. // Protected constructor where the derived class must initialize all pointers
  1339. //
  1340. inline
  1341. TRegLink::TRegLink()
  1342. :
  1343.   Next(0),
  1344.   RegList(0)
  1345. {
  1346.  
  1347. }
  1348.  
  1349.  
  1350. //----------------------------------------------------------------------------
  1351. // TRegTemplateList
  1352. //
  1353.  
  1354. //
  1355. // Return the number of templates in this list
  1356. //
  1357. inline int
  1358. TRegTemplateList::GetCount() const
  1359. {
  1360.   return Count;
  1361. }
  1362.  
  1363. //
  1364. // Return the registry key upon which these templates are based
  1365. //
  1366. inline TRegKey&
  1367. TRegTemplateList::GetBaseKey()
  1368. {
  1369.   return BaseKey;
  1370. }
  1371.  
  1372. //
  1373. // Return the template string at the passed index.
  1374. // Note: The list is indexed beginning with 1 not 0.
  1375. //
  1376. inline const _TCHAR*
  1377. TRegTemplateList::operator [](int i)
  1378. {
  1379.   PRECONDITION(i > 0 && i <= Count);
  1380.   if (i <= 0 || i > Count)
  1381.     return 0;
  1382.   else
  1383.     return List[i-1];
  1384. }
  1385.  
  1386. //
  1387. // Disable all templates in this list
  1388. //
  1389. inline void
  1390. TRegTemplateList::DisableAll()
  1391. {
  1392.   memset(EnabledFlags, 0x80, Count);
  1393. }
  1394.  
  1395. //
  1396. // Enable all templates in this list
  1397. //
  1398. inline void
  1399. TRegTemplateList::EnableAll()
  1400. {
  1401.   memset(EnabledFlags, 0x00, Count);
  1402. }
  1403.  
  1404. //
  1405. // Enable the template at the passed index
  1406. // Note: The list is indexed beginning with 1 not 0.
  1407. //
  1408. inline void
  1409. TRegTemplateList::Enable(int i)
  1410. {
  1411.   PRECONDITION(i > 0 && i <= Count);
  1412.   if (i > 0 && i <= Count)
  1413.     EnabledFlags[i-1] = 0;
  1414. }
  1415.  
  1416. //
  1417. // Activate the template at the passed index
  1418. // Note: The list is indexed beginning with 1 not 0.
  1419. //
  1420. inline void
  1421. TRegTemplateList::Activate(int i)
  1422. {
  1423.   PRECONDITION(i > 0 && i <= Count);
  1424.   if (i > 0 && i <= Count)
  1425.     EnabledFlags[i-1]++;
  1426. }
  1427.  
  1428. //
  1429. // Returns true if the template at the passed index is active, false otherwise.
  1430. // Note: The list is indexed beginning with 1 not 0.
  1431. //
  1432. inline bool
  1433. TRegTemplateList::IsActive(int i) const
  1434. {
  1435.   PRECONDITION(i > 0 && i <= Count);
  1436.   if (i > 0 && i <= Count)
  1437.     return EnabledFlags[i-1] > 0;
  1438.   else
  1439.     return false;
  1440. }
  1441.  
  1442. //----------------------------------------------------------------------------
  1443. // TRegParamList
  1444. //
  1445.  
  1446. //
  1447. // Return the number of param entries in this list
  1448. //
  1449. inline int
  1450. TRegParamList::GetCount() const
  1451. {
  1452.   return Count;
  1453. }
  1454.  
  1455. //
  1456. // Return the template string at the passed index.
  1457. //
  1458. inline TRegParamList::TEntry&
  1459. TRegParamList::operator [](int i)
  1460. {
  1461.   PRECONDITION(i >= 0 && i < Count);
  1462.   if (i < 0 || i >= Count)
  1463.     TXRegistry::Check(1,0);
  1464.   return List[i];
  1465. }
  1466.  
  1467.  
  1468. //
  1469. // Return the value of the param entry at the passed index
  1470. //
  1471. inline const _TCHAR*&
  1472. TRegParamList::Value(int i)
  1473. {
  1474.   PRECONDITION(i >= 0 && i < Count);
  1475.   return Values[i];
  1476. }
  1477.  
  1478. #endif  // WINSYS_REGISTRY_H
  1479.